package cn.mo.dq.nacoscloudconfig.controller;

import cn.mo.dq.nacosprovider.service.TestService;
import com.alibaba.nacos.api.config.annotation.NacosValue;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created with hz
 *
 * @Author: hz
 * @Date: 2023/04/08/22:07
 * @Description:
 */
@RestController
@RequestMapping("config")
public class DiscoveryController {

    @DubboReference(check = false)
    TestService testService;

    @NacosValue(value = "${useLocalCache:false}", autoRefreshed = true)
    private boolean useLocalCache;

    @Value(value = "${config}")
    private String nacosConfig;


    @GetMapping("/getConfig")
    @ResponseBody
    public String getConfig() {
        return nacosConfig;
    }

    @GetMapping("/testDubbo")
    @ResponseBody
    private String testDubbo(){
       return testService.show();
    }
}
